//广度优先遍历

const bt = require('./bt')

var minDepth = function(root) {
  if (!root) {return}
  let res = 1
  const q = [[root, 1]]
  while (q.length > 0) {
    const [n, l] = q.shift()
    if (!n.left && !n.right) {
      return l
    }
    if (n.left) q.push([n.left, l+1])
    if (n.right) q.push([n.right, l+1])
  }
}

minDepth(bt)
